import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class, _class2;

import React from 'react';
import { Modal, Input, Form } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
var FormItem = Form.Item;
var formItemLayout = {
  labelCol: {
    sm: {
      span: 6
    }
  },
  wrapperCol: {
    sm: {
      span: 14
    }
  }
};
var MultiInfoModal = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(MultiInfoModal, _React$Component);

  var _super = _createSuper(MultiInfoModal);

  function MultiInfoModal() {
    _classCallCheck(this, MultiInfoModal);

    return _super.apply(this, arguments);
  }

  _createClass(MultiInfoModal, [{
    key: "handleOk",
    value: function handleOk() {
      var _this$props = this.props,
          form = _this$props.form,
          onOk = _this$props.onOk;
      form.validateFields(function (err, values) {
        if (!err) {
          onOk(values);
        }
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          visible = _this$props2.visible,
          onCancel = _this$props2.onCancel,
          form = _this$props2.form,
          _this$props2$modalDat = _this$props2.modalData,
          modalData = _this$props2$modalDat === void 0 ? [] : _this$props2$modalDat,
          _this$props2$label = _this$props2.label,
          label = _this$props2$label === void 0 ? intl.get('cpaas.common.button.edit').d('编辑') : _this$props2$label,
          _this$props2$width = _this$props2.width,
          width = _this$props2$width === void 0 ? '520px' : _this$props2$width;
      var getFieldDecorator = form.getFieldDecorator;
      return /*#__PURE__*/React.createElement(Modal, {
        destroyOnClose: true,
        title: label,
        width: width,
        visible: visible,
        onCancel: onCancel,
        onOk: this.handleOk
      }, /*#__PURE__*/React.createElement(Form, null, modalData.map(function (item) {
        return /*#__PURE__*/React.createElement(FormItem, Object.assign({
          label: item.meaning || item.lang,
          key: item.lang
        }, formItemLayout), getFieldDecorator(item.lang, {
          initialValue: item.value
        })( /*#__PURE__*/React.createElement(Input, null)));
      })), modalData.length === 0 && intl.get('cimp.template.view.message.title.noMaintain').d('未维护多语言类型导入模版!!'));
    }
  }]);

  return MultiInfoModal;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "handleOk", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "handleOk"), _class2.prototype)), _class2)) || _class);
export { MultiInfoModal as default };